#
# Copyright 2022 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

if(TARGET pthreadpool OR pthreadpool_POPULATED)
	return()
  endif()
  
include(FetchContent)

OverridableFetchContent_Declare(
  pthreadpool
  #GIT_REPOSITORY https://gitee.com/lingongheng/pthreadpool.git
#   URL https://github.com/Maratyszcza/pthreadpool/archive/545ebe9f225aec6dca49109516fac02e973a3de2.zip
  #   URL_HASH SHA256=8461f6540ae9f777ce20d1c0d1d249e5e61c438744fb390c0c6f91940aa69ea3
GIT_TAG 545ebe9f225aec6dca49109516fac02e973a3de2
  SOURCE_DIR "${CMAKE_BINARY_DIR}/pthreadpool-source"
  BINARY_DIR "${CMAKE_BINARY_DIR}/pthreadpool"
  GIT_PROGRESS TRUE
  PREFIX "${CMAKE_BINARY_DIR}"
)
OverridableFetchContent_GetProperties(pthreadpool)
if(NOT pthreadpool_POPULATED)
  OverridableFetchContent_Populate(pthreadpool)
endif()

set(PTHREADPOOL_SOURCE_DIR "${pthreadpool_SOURCE_DIR}" CACHE PATH "pthreadpool source directory")

add_subdirectory(
  "${pthreadpool_SOURCE_DIR}"
  "${pthreadpool_BINARY_DIR}"
)
